import { createHashRouter, RouterProvider } from 'react-router-dom'

import { Loading } from '@/components/Loading'
import { routes } from './routes'

const router = createHashRouter(routes, {
  future: {
    v7_fetcherPersist: true,
    v7_normalizeFormMethod: true,
    v7_relativeSplatPath: true,
    v7_skipActionErrorRevalidation: true,
  },
  window,
})

export const RouterConfig = function () {
  return <RouterProvider router={router} fallbackElement={<Loading />} future={{ v7_startTransition: true }} />
}
